package com.scy.java.Test.Test02;

public class DemoTest {
    public static void main(String[] args) {
        doWhileTest();
        whileTest();
        forTest();
    }
//    求10以内的和
    public static void doWhileTest(){
        int i = 1;
        int sum = 0;
        do {
            sum+=i;
           i++;
        }while (i<=10);
        System.out.println("do while十以内的和为："+sum);
    }
    public static void whileTest(){
        int i = 1;
        int sum = 0;
        while (i<=10){
            sum+=i;
            i++;
        }
        System.out.println("while十以内的和为："+sum);
    }
    public static void forTest(){
        int sum = 0;
        for (int i = 0; i <= 10; i++) {
            sum+=i;
        }
        System.out.println("for十以内的和为："+sum);

    }

}
